﻿using System;
using System.Windows.Forms;

namespace PPRecorder
{
    public partial class SaveForm : Form
    {
        public SaveForm()
        {
            InitializeComponent();
        }

        private void saveForm_Load(object sender, EventArgs e)
        {
            lootboxChoice.Items.Add("Vine-Cracked Junkbox");
            lootboxChoice.Items.Add("Heavy Junkbox");
        }

        private void cancelSavebtn_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        #region PPRecorder Buttons

        // Save Profile - Attempts to save the profile
        private void saveProfilebtn_Click(object sender, EventArgs e)
        {
            var s = String.Empty;
            var c = String.Empty;
            if (InputBox.ShowDialog("Create your profile", ref s, ref c) == DialogResult.Cancel) return;

            var lootbox = lootboxChoice.SelectedItem.ToString(); // update this pls

            var lootboxEntry = 0; // update this pls

            switch (lootbox)
            {
                case ("Vine-Cracked Junkbox"):
                    lootboxEntry = 88165;
                    break;
                case("Heavy Junkbox"):
                    lootboxEntry = 16885;
                    break;
                default:
                    lootboxEntry = 88165;
                    break;
            }

            var minFBagSlots = minFreeSlotsSlider.Value;

            var sgrey = false;
            var swhite = false;
            var sgreen = false;
            var sblue = false;
            var spurple = false;
            var mgrey = false;
            var mwhite = false;
            var mgreen = false;
            var mblue = false;
            var mpurple = false;

            if (sellGreyY.Checked)
            {
                sgrey = true;
            }
            if (sellWhiteY.Checked)
            {
                swhite = true;
            }
            if (sellGreenY.Checked)
            {
                sgreen = true;
            }
            if (sellBlueY.Checked)
            {
                sblue = true;
            }
            if (sellPurpleY.Checked)
            {
                spurple = true;
            }
            if (mailGreyY.Checked)
            {
                mgrey = true;
            }
            if (mailWhiteY.Checked)
            {
                mwhite = true;
            }
            if (mailGreenY.Checked)
            {
                mgreen = true;
            }
            if (mailBlueY.Checked)
            {
                mblue = true;
            }
            if (mailPurpleY.Checked)
            {
                mpurple = true;
            }

            XMLCreator xml = new XMLCreator();
            if (xml.makeXML(s, c, lootbox, lootboxEntry, minFBagSlots, sgrey, swhite, sgreen, sblue, spurple, mgrey, mwhite, mgreen, mblue, mpurple))
            {
                this.Hide();
            };
        }


        // Recommended Settings - Sets all the values to recommendation
        private void rcmdSettings_Click(object sender, EventArgs e)
        {
            sellGreyY.Checked = true;
            sellWhiteN.Checked = true;
            sellGreenN.Checked = true;
            sellBlueN.Checked = true;
            sellPurpleN.Checked = true;
            mailGreyN.Checked = true;
            mailWhiteY.Checked = true;
            mailGreenY.Checked = true;
            mailBlueY.Checked = true;
            mailPurpleY.Checked = true;
            minFreeSlotsSlider.Value = 4;
        }
        #endregion

        private void minFreeSlotsSlider_Scroll(object sender, EventArgs e)
        {
            toolTip1.SetToolTip(minFreeSlotsSlider, minFreeSlotsSlider.Value.ToString());
        }

        
    }
}
